import numpy as np
import PIL.Image as Image
import patchreconst as pr

PATCH_SIZE = 32
COMPONENT_COUNT = 100
PATCH_COUNT = 400000
EPOCH_COUNT = 16
CODE_COUNT = 800
SPARSITY_PARAMETER = 0.5
NON_NEGATIVE = True

scBasisFile = 'basis/basisnn' + str(NON_NEGATIVE) + 'lamb' + str(SPARSITY_PARAMETER) + 'comps' + str(COMPONENT_COUNT) + 'codes' + str(CODE_COUNT) + 'patches' + str(PATCH_COUNT) + 'epochs' + str(EPOCH_COUNT) + '.npy'
scBasis = np.load(scBasisFile)

icaFilterFile = 'icabasis/basisluisicacomps' + str(COMPONENT_COUNT) + 'codes' + str(CODE_COUNT) + 'patches' + str(PATCH_COUNT) + '.npy'
icaFilters = np.load(icaFilterFile)

patches = np.load('patches_1000.npy')[:, :, :, 0]

scCodes, icaCodes, v1Simple, v1SimpleCropped, v1cMean, angles = pr.responsesCropV1(patches, scBasis, SPARSITY_PARAMETER, NON_NEGATIVE, icaFilters)

patchesReconstSC = pr.reconstructForV1(scBasis, scCodes, v1cMean, angles)
patchesReconstICA = pr.reconstructForV1(icaFilters, icaCodes, v1cMean, angles)
